package cn.HL.org.service.impl;

import cn.HL.basic.query.BaseQuery;
import cn.HL.basic.service.impl.BaseServiceImpl;
import cn.HL.basic.util.PageList;
import cn.HL.org.domain.Employee;
import cn.HL.org.domain.Systemdictionarydetail;
import cn.HL.org.domain.Systemdictionarytype;
import cn.HL.org.mapper.EmployeeMapper;
import cn.HL.org.mapper.SystemdictionarydetailMapper;
import cn.HL.org.mapper.SystemdictionarytypeMapper;
import cn.HL.org.service.ISystemdictionarytypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class SystemdictionarytypeServiceImpl  extends BaseServiceImpl<Systemdictionarytype> implements ISystemdictionarytypeService {
    @Autowired
    private SystemdictionarytypeMapper systemdictionarytypeMapper;
    @Autowired
    private SystemdictionarydetailMapper systemdictionarydetailMapper;

    @Override
    @Transactional
    public void removeById(Long id) {
        try {
            List<Systemdictionarydetail> list = systemdictionarydetailMapper.findBy(id);
            List<Long> ids = new ArrayList<>();
            for (Systemdictionarydetail systemdictionarydetail : list) {
                Long id1 = systemdictionarydetail.getId();
                ids.add(id1);
            }

            systemdictionarydetailMapper.batchDelDept(ids);

        }catch (Exception e){
            e.printStackTrace();

        }finally {
            systemdictionarytypeMapper.deleteById(id);
        }







    }


    @Override
    @Transactional
    public void batchDelDept(List<Long> ids) {
        try {
            List<Systemdictionarydetail> byidall = systemdictionarydetailMapper.findByidall(ids);
                List<Long> idss = new ArrayList<>();
                for (Systemdictionarydetail systemdictionarydetail : byidall) {
                    Long id1 = systemdictionarydetail.getId();
                    idss.add(id1);
                }
            System.out.println(idss);
            systemdictionarydetailMapper.batchDelDept(idss);


        }catch (Exception e){

        }finally {
            systemdictionarytypeMapper.batchDelDept(ids);
        }


    }
}
